package umt.cs.cs241.Assignment1.c_1_1;

import java.util.Random;

/*
 * Chris Hanshew
 * CS 241 Assignment 1
 * 9/9/08
 * C 1.1
 */

public class Driver_c_1_1 {

	public static void main(String [] args){
		
		int arraySize = 10;
		
		oddProduct(getRandomIntArray(arraySize));
	}
	
	/**
	 * Accepts an array of int values and determines if the product of any two values is odd.
	 * 
	 * @param numbers An array of interger values
	 */
	public static void oddProduct(int [] numbers ){
		
		//Outer loop 
		for(int i = 0; i < numbers.length; i++){
			
			//Inner loop where the iterator is the value of n + 1 where n is the value of the iterator of the outer loop.
			for(int c = i + 1; c < numbers.length; c++ ){
				
				//Save the value of the remainder of the two numbers after calculating against modulus.
				int remainder = ((numbers[i] * numbers[c]) % 2);
				
				//If a remainder exists, the number is odd and the user is alerted.
				if(remainder != 0){
					System.out.print("The product of the numbers at ");
					System.out.print("index: " + i + " (" + numbers[i] + ")");
					System.out.print(" and ");
					System.out.print("index: " + c + " (" + numbers[c] + ")");
					System.out.print(" is odd. ");
					System.out.print("(" +(numbers[i] * numbers[c]) + ")\n\n");
				}
				
			}
		}
	}
	
	/**
	 * Returns an array of random int values with an array size specified by the user.
	 * 
	 * @param arraySize The number of values a user wishes to place in the returned array.
	 * @return randomNumbers An array of random number values
	 */
	public static int[] getRandomIntArray(int arraySize){
		
		Random randomGen = new Random();
		
		int [] randomNumbers = new int[arraySize];
		
		for(int i = 0; i < (arraySize - 1); i++){
			randomNumbers[i] = randomGen.nextInt(25) + 1;
		}
		
		return randomNumbers;
		
	}
}
